﻿using FriendAnalyzer.Business;
using FriendAnalyzer.Infrastructure.Facebook.Interfaces;
using FriendAnalyzer.UI.Views;
using FriendAnalyzer.UI.Views.Errors;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;

namespace FriendAnalyzer.UI.Helpers
{
    public class NavigateHelper
    {
        private bool NavigateTo<T>(object parameter = null)
        {
            var frame = Window.Current.Content as Frame;
            if (parameter != null)
            {
                return frame.Navigate(typeof(T), parameter);
            }
            else
            {
                return frame.Navigate(typeof(T));
            }
        }

        public bool ToGenericError(string errorMessage)
        {
            return NavigateTo<GenericErrorView>(errorMessage);
        }
        public bool ToNotAuthenticatedError()
        {
            return NavigateTo<NotAuthenticatedView>();
        }

        public bool ToLoginPage()
        {
            return NavigateTo<LoginPage>();
        }
        public bool ToMainPage(AggregateService service)
        {
            return NavigateTo<MainPage>(service);
        }
    }
}